package pe.com.tma.bean;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.primefaces.component.chart.series.ChartSeries;
import org.primefaces.model.chart.CartesianChartModel;

import pe.com.tma.model.Cotizacion;
import pe.com.tma.model.Indice;
import pe.com.tma.service.CotizacionService;

public class CotizacionBean implements Serializable{
	
	private CartesianChartModel cartesianModel; 
	private  List<Cotizacion> cotiAlzas;
	private  List<Cotizacion> cotiBajas;
	private  List<Cotizacion> cotiMasNeg;
	private List<Indice> indices;
	
	
	public CotizacionBean(){
		createCartesianModel();
		cargaCoti();
	}
	private void cargaCoti(){
		CotizacionService srv = new CotizacionService();
		cotiAlzas = srv.getAlzas();
		cotiBajas = srv.getBajas();
		cotiMasNeg = srv.getMasNeg(); 
		loadIndices();
	}
	
	private void loadIndices(){
		indices =  new ArrayList<Indice>();
		Indice ind;
		
		ind = new Indice("IGBVL",23775.49,(	23775.49 - 23777.04),-0.01);
		indices.add(ind);
		ind = new Indice("ISBVL",32615.67,(32615.67 - 32607.20),0.03);
		indices.add(ind);
		ind = new Indice("IBGC",167.77,(167.77 -167.43),0.20);
		indices.add(ind);
		ind = new Indice("INCA",127.07,(127.07 -126.99),0.06);
		indices.add(ind);

	}
	
	private void createCartesianModel() {
        cartesianModel = new CartesianChartModel();

        ChartSeries boys = new ChartSeries();
        boys.setLabel("Boys");

        boys.set("2004", 120);
        boys.set("2005", 100);
        boys.set("2006", 44);
        boys.set("2007", 150);
        boys.set("2008", 25);
        boys.set("2009", 120);
        boys.set("2010", 135);
        cartesianModel.addSeries(boys);
    }

	public CartesianChartModel getCartesianModel() {
		return cartesianModel;
	}

	public void setCartesianModel(CartesianChartModel cartesianModel) {
		this.cartesianModel = cartesianModel;
	}

	public List<Cotizacion> getCotiAlzas() {
		return cotiAlzas;
	}

	public List<Cotizacion> getCotiBajas() {
		return cotiBajas;
	}
	
	public List<Cotizacion> getCotiMasNeg() {
		return cotiMasNeg;
	}
	public List<Indice> getIndices() {
		return indices;
	}

	
	
}
